package com.sicheng.lc;

import java.util.*;

/**
 * @author zsc
 * @version 1.0
 * @date 2022/8/10 18:30
 */
public class 捉迷藏 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
        List<Integer>[] g = new List[n + 1];
        Arrays.setAll(g, k -> new ArrayList<>(100));
        for (int i = m; i > 0; i--) {
            int x = in.nextInt();
            int y = in.nextInt();
            g[x].add(y);
            g[y].add(x);
        }

        ArrayDeque<Integer> deque = new ArrayDeque<>();
        deque.offer(1);
        boolean[] visit = new boolean[n + 1];
        visit[1] = true;
        int step = -1;
        int min = n + 1;
        int cnt = 0;
        // 从1开始bfs拓展结点
        while (!deque.isEmpty()) {
            // 记录层数
            step++;
            // 记录每层里最小的点
            min = deque.peek();
            int size = deque.size();
            for (int i = 0; i < size; i++) {
                int a = deque.poll();
                min = Math.min(min, a);
                for (int b : g[a]) {
                    if (!visit[b]) {
                        deque.offer(b);
                        visit[b] = true;
                    }
                }
            }
            if (deque.size() == 0) {
                //最后一层的点的个数 也就是最远点的数量
                cnt = size;
            }
        }

        System.out.printf("%d %d %d", min, step, cnt);

    }
}
